package com.yue.design.composite;

import java.util.ArrayList;
import java.util.List;

public class MyFolder extends MyDirectory {
    List<MyDirectory> list = new ArrayList<>();
    private Integer level;
    public MyFolder(String name,Integer level) {
        super(name);
        this.level= level;
    }

    @Override
    public void show() {
        System.out.println(name);
        for(MyDirectory d:list){
            for (int i=0;i<level;i++){
                System.out.print("  ");
            }
            d.show();
        }

    }
    public void add(MyDirectory directory){
        this.list.add(directory);
    }
    public void remove(MyDirectory directory){
        this.list.remove(directory);
    }
    public MyDirectory remove(int index){
        return this.list.get(index);
    }
}
